const OK =200
import {getBaseCategoryList,getBanners,getFloor} from 'http'
export default {
    state:{
        categoryList:[],
        banners:[],
        floor:[]
    },
    getters:{},
    mutations:{
        getCategoryList(state,categoryList){
            state.categoryList = categoryList
        },
        getBanners(state,banners){
            state.banners = banners
        },
        getFloor(state,floor){
            state.floor = floor
        }
    },
    actions:{
        async getCategoryList({commit}){
            const {code,data} = await getBaseCategoryList()
            if(code === OK)
                commit('getCategoryList',data.filter((item,index) => index < 15))
            return data
        },
        async getBanners({commit}){
            const {code,data} = await getBanners()
            if(code === OK)
            commit('getBanners',data)
        },
        async getFloor({commit}){
            const {code,data} = await getFloor()
            if(code === OK)
            commit('getFloor',data)
            // console.log(data)
        }
    }
}